package day04;


import java.util.Scanner;

public class Gueesing1 {
    public static void main(String[] args) {

        int a = (int) (Math.random() * 100) + 1;
        System.out.println(a);
        boolean b = true;
        int count = 0;
        Scanner scanner = new Scanner(System.in);
        while (b) {
            count++;
            System.out.println("请输入你猜的数字：");
            int sc = scanner.nextInt();
            if (sc <= 100 && sc >= 0) {
                if (a < sc) {
                    System.out.println("哈哈，你猜得" + sc + "大了\t");
                } else if (a > sc) {
                    System.out.print("哈哈，你猜得" + sc + "小了\t");
                } else {
                    System.out.println("恭喜你 猜对了,您一共猜了" + count + "次");

                    b = false;

                }
            } else {
                System.out.println("您输入有误，请重新输入，要求0-100");

            }
        }
    }
}
